package org.hyf.inspur.LessonDesin.clear.wordcount;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;


public class WordCountMain {

	public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
		Configuration conf = new Configuration();
		conf.set("fs.default","hdfs://localhost:9000");
		Job job=Job.getInstance();
		job.setJarByClass(WordCountMain.class);
		job.setMapperClass(WordCountMapper.class);
		job.setReducerClass(WordCountReducer.class);
//		job.setNumReduceTasks(0);
		//定义了输出数据类型
	    job.setOutputKeyClass(Text.class);
	    job.setOutputValueClass(IntWritable.class);
		 //输入输出 文件路径配置
	    FileInputFormat.addInputPath(job, new Path("D:/BigData/student.txt"));
	    FileOutputFormat.setOutputPath(job,
	    	      new Path("D:/BigData/output1"));
		//boolean jude = job.waitForCompletion(true);
		System.exit(job.waitForCompletion(true) ? 0 : 1);

	}

}
